// src/store/auth.js
import { defineStore } from "pinia";

export const useAuthStore = defineStore("auth", {
  state: () => ({
    isLoggedIn: false,
    user: null,
  }),

  actions: {
    login(username, password) {
      // 模拟登录逻辑
      this.isLoggedIn = true;
      this.user = { id: 1, username };
      localStorage.setItem("token", "fake_token");
    },

    logout() {
      this.isLoggedIn = false;
      this.user = null;
      localStorage.removeItem("token");
    },
  },
});
